package ms.core.gateway.request;

import java.util.Map;

import lombok.Data;
import ms.core.common.AppException;
import ms.core.common.consts.SysErr;
import ms.core.tool.JsonTool;
import ms.core.tool.StrTool;

@Data
public class GetTokenRequest {
	private String clientId;
	private String clientSecret;
	
	public static GetTokenRequest getInstance(Map<String, Object> body) {
		GetTokenRequest req = JsonTool.objectToBean(body, GetTokenRequest.class);
		if (req==null) throw new AppException(SysErr.SYS_PARAM_ERR);
		
		if (StrTool.isBlank(req.getClientId()) || StrTool.isBlank(req.getClientSecret()))
			throw new AppException(SysErr.SYS_PARAM_ERR, "请输入ClientId和ClientSecret参数值.");
		
		return req;
	}
}
